/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.woupla.model;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dimi
 */
@Entity
@Table(name = "planing")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "findAll", query = "SELECT p FROM Planing p"),
    @NamedQuery(name = "findByEmployee", query = "SELECT p FROM Planing p WHERE p.user = :employee "),
    @NamedQuery(name = "findByEmployeeSemaine", query = "SELECT p FROM Planing p WHERE p.user = :employee AND p.planingPK.semaine BETWEEN :debut AND :fin"),
    @NamedQuery(name = "Planing.findByEmployeeStatic", query = "SELECT p FROM Planing p WHERE p.user = :employee AND p.status = 1"),
    @NamedQuery(name = "Planing.findByCompany", query = "SELECT p FROM Planing p, Company c , City y ,Adress a WHERE p.company = c AND c.adress = a AND y = a.city AND p.status = 2 AND y.label = :city"),
    @NamedQuery(name = "Planing.findByCompanyStatic", query = "SELECT p FROM Planing p WHERE p.company = :company AND p.status = 1"),
    @NamedQuery(name = "findBySemaine", query = "SELECT p FROM Planing p WHERE p.planingPK.semaine = :semaine"),
    @NamedQuery(name = "findByAnnee", query = "SELECT p FROM Planing p WHERE p.annee = :annee"),
    @NamedQuery(name = "findByStatus", query = "SELECT p FROM Planing p WHERE p.status = :status"),
    @NamedQuery(name = "findByLundi", query = "SELECT p FROM Planing p WHERE p.lundi = :lundi"),
    @NamedQuery(name = "findByMardi", query = "SELECT p FROM Planing p WHERE p.mardi = :mardi"),
    @NamedQuery(name = "findByMercredi", query = "SELECT p FROM Planing p WHERE p.mercredi = :mercredi"),
    @NamedQuery(name = "findByJeudi", query = "SELECT p FROM Planing p WHERE p.jeudi = :jeudi"),
    @NamedQuery(name = "findByVendredi", query = "SELECT p FROM Planing p WHERE p.vendredi = :vendredi"),
    @NamedQuery(name = "findBySamedi", query = "SELECT p FROM Planing p WHERE p.samedi = :samedi"),
    @NamedQuery(name = "findByDimanche", query = "SELECT p FROM Planing p WHERE p.dimanche = :dimanche")})
public class Planing implements Serializable {
    
    /**
	 * 
	 */
	private static final long serialVersionUID = 5304828917409549838L;
	@EmbeddedId
    protected PlaningPK planingPK;
    @Column(name = "annee")
    private Integer annee;
    @Column(name = "status")
    private Integer status;
    @Column(name = "lundi")
    private String lundi;
    @Column(name = "mardi")
    private String mardi;
    @Column(name = "mercredi")
    private String mercredi;
    @Column(name = "jeudi")
    private String jeudi;
    @Column(name = "vendredi")
    private String vendredi;
    @Column(name = "samedi")
    private String samedi;
    @Column(name = "dimanche")
    private String dimanche;
    @JoinColumn(name = "employee_id", referencedColumnName = "id", updatable = false)
    @ManyToOne(optional = false)
    private User user;
    @OneToOne
    private Company company;

    public Planing() {
    }

    public Planing(PlaningPK planingPK) {
        this.planingPK = planingPK;
    }

    public Planing(int employeeId, int semaine) {
        this.planingPK = new PlaningPK(employeeId, semaine);
    }

    public PlaningPK getPlaningPK() {
        return planingPK;
    }

    public void setPlaningPK(PlaningPK planingPK) {
        this.planingPK = planingPK;
    }

    public Integer getAnnee() {
        return annee;
    }

    public void setAnnee(Integer annee) {
        this.annee = annee;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getLundi() {
        return lundi;
    }

    public void setLundi(String lundi) {
        this.lundi = lundi;
    }

    public String getMardi() {
        return mardi;
    }

    public void setMardi(String mardi) {
        this.mardi = mardi;
    }

    public String getMercredi() {
        return mercredi;
    }

    public void setMercredi(String mercredi) {
        this.mercredi = mercredi;
    }

    public String getJeudi() {
        return jeudi;
    }

    public void setJeudi(String jeudi) {
        this.jeudi = jeudi;
    }

    public String getVendredi() {
        return vendredi;
    }

    public void setVendredi(String vendredi) {
        this.vendredi = vendredi;
    }

    public String getSamedi() {
        return samedi;
    }

    public void setSamedi(String samedi) {
        this.samedi = samedi;
    }

    public String getDimanche() {
        return dimanche;
    }

    public void setDimanche(String dimanche) {
        this.dimanche = dimanche;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    /**
	 * @return the company
	 */
	public Company getCompany() {
		return company;
	}

	/**
	 * @param company the company to set
	 */
	public void setCompany(Company company) {
		this.company = company;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (planingPK != null ? planingPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Planing)) {
            return false;
        }
        Planing other = (Planing) object;
        if ((this.planingPK == null && other.planingPK != null) || (this.planingPK != null && !this.planingPK.equals(other.planingPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Planing[ planingPK=" + planingPK + " ]";
    }
    
}
